import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const Home = resolve => require(['../views/Home'], resolve)

const state = {
    activeTabName: "home",
    tabList: [
       
    ]
}

const mutations = {
    setActiveTabName(state, name) {
        state.activeTabName = name;
    },
    addTabs (state, data) {
        state.tabList.push(data);
    },
    closeTab(state, name) {
        let tab = state.tabList.filter(f => f.name == name)[0];
        let index = state.tabList.indexOf(tab);
        if (index != state.tabList.length - 1) {
            state.activeTabName = state.tabList[index + 1].name;
        } else {
            state.activeTabName = state.tabList[index - 1].name;
        }
        state.tabList = state.tabList.filter(f => f.name != name);
    }
}

export default{
    namespaced: true,
    state,
    mutations,
    actions: {

    }
}


